package com.spring.bean.service;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

/**
 * 每一行代码，都是改变世界的力量
 *
 * @author 郭帅
 * @date 2022/11/30 17:20
 */
//@Component
public class BeanFactoryAwareTest implements ApplicationContextAware {

    public void test(){
        System.out.println("---");
    }

    private BeanFactory factory;
//
//    @Override
//    public void setBeanFactory(@NonNull BeanFactory beanFactory) throws BeansException {
//        this.factory = beanFactory;
//        DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory;
//        BeanDefinition locationBeanDefinition = new RootBeanDefinition(People.class);
//        listableBeanFactory.registerBeanDefinition("people", locationBeanDefinition);
//    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("---");
    }
}
